home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1994-10-01 | 3.8 KB | 175 lines | [ TEXT/MMCC]
/******************************************** **** ACL-World **** **** Controls.cp **** **** Created: 29 August 1994 **** Modified: 30 August 1994 **** Version: 0 **** Compatible: C++, Mac System 7 **** **** Description: Scrolling demo. **** *******************/ #include "ACL-World.h" //************************************* static const short PICT_BACKGROUND = 178; static const short PICT_BACKGROUND2 = 182; //************************************* #define TEXTSTEP1 "\pA background picture may be bigger than the view rectangle. In this case the view rectangle may be scrolled in the background picture. Use the arrows of your keyboard to scroll the view." #define TEXTSTEP2 "\pACL is able to do circular scrollings. It means that when the visible rectangle scrolls out of the background ACL redisplays the left/top part of the image. Use the arrows of your keyboard to scroll the view." //************************************* static AnimGfx *background; static short backwidth,backheight; static Anim *anims[1]; //************************************* Boolean ACLWorld::scrolling_advance(void) { short i; Handle ha; Rect rect; static short w,h; step++; GetDItem(dialog,1,&i,&ha,&rect); switch(step) { case 1: SetIText(ha,TEXTSTEP1); animbase->installbackground(background); anims[0] = animbase->createanim(animpers); anims[0]->setsequence(2); anims[0]->findcursize(&w,&h); anims[0]->place(150-(w/2),100-(h/2)); return FALSE; case 2: SetIText(ha,TEXTSTEP2); background = animbase->newgfx(PICT_BACKGROUND2); animbase->installbackground(background); backwidth = background->getwidth(); backheight = background->getheight(); ((AnimScrollBase*)animbase)->setscrolloffsetx((backwidth/2) - 150); ((AnimScrollBase*)animbase)->setscrolloffsety((backheight/2) - 100); return FALSE; } return TRUE; } //************************************* Boolean ACLWorld::do_scrolling(void) { Point p; char key; short res; Boolean done = FALSE; AnimScrollBase *animbase; pleasewait(TRUE); ACLWorld::animbase = animbase = new AnimScrollBase(); background = animbase->newgfx(PICT_BACKGROUND); animbase->newgfx(PICT_BACKGROUND2); animbase->preload_framedef(animpers); backwidth = background->getwidth(); backheight = background->getheight(); animbase->buildbuffer(300,200); animbase->setbasex(17+80); animbase->setbasey(8+7); animbase->setscrolloffsetx((backwidth/2) - 150); animbase->setscrolloffsety((backheight/2) - 100); pleasewait(FALSE); step = 0; openbasedialog(); SetWTitle(dialog,"\pScrolling"); scrolling_advance(); for(;;) { if (step==1) { if (animbase->getscrolloffsetx()+animbase->gethscrollvect()<0 || (animbase->getscrolloffsetx()+animbase->gethscrollvect()+300>=backwidth)) animbase->sethscrollvect(0); if (animbase->getscrolloffsety()+animbase->getvscrollvect()<0 || (animbase->getscrolloffsety()+animbase->getvscrollvect()+200>=backheight)) animbase->setvscrollvect(0); } res = processbasedialog(key,p); if (res==DO_QUIT) {done=TRUE; break;} else if (res==DO_MENU) break; else if (res==DO_CONTINUE && scrolling_advance()) break; else if (res==DO_KEY) { switch(key) { case 28: animbase->sethscrollvect(-3); break; case 29: animbase->sethscrollvect(3); break; case 30: animbase->setvscrollvect(-3); break; case 31: animbase->setvscrollvect(3); break; } } else if (res==DO_KEYUP) { switch(key) { case 28: animbase->sethscrollvect(0); break; case 29: animbase->sethscrollvect(0); break; case 30: animbase->setvscrollvect(0); break; case 31: animbase->setvscrollvect(0); break; } } } closebasedialog(); delete animbase; return done; } //*************************************